/**
 * @description 前端路由配置
 * @author 盘古他爹
 */

import { roleTypes, IFrontRouterConfig, IFrontRouterConfigKey, IKey } from "./types"




const menus: IFrontRouterConfig = {
    list: {
        data: [
            {
                sqlName: "list_panda_kill",
                menuName: "狼人杀pandaKill",
                icon: "el-icon-cherry",
                roles: [roleTypes.boss, roleTypes.leader, roleTypes.farmer],
                url: "pandaKill"
            }
        ],
        roles: [roleTypes.boss, roleTypes.leader, roleTypes.farmer],
        name: "列表大全",
        icon: "el-icon-document-remove",
        url: "list/"
    },

    dataShow: {
        data: [
            {
                sqlName: "list_panda_kill",
                menuName: "数据可视化",
                icon: "el-icon-cherry",
                roles: [roleTypes.boss, roleTypes.leader],
                url: "python"
            }
        ],
        roles: [roleTypes.boss, roleTypes.leader, roleTypes.farmer],
        name: "图片",
        icon: "el-icon-cherry",
        url: "dataShow/"
    },

    pic: {
        data: [
            {
                sqlName: "list_panda_kill",
                menuName: "聊天会话",
                icon: "el-icon-cherry",
                roles: [roleTypes.boss, roleTypes.leader, roleTypes.farmer],
                url: "pic"
            }
        ],
        roles: [roleTypes.boss, roleTypes.leader],
        name: "对话列表",
        icon: "el-icon-cherry",
        url: "pic/"
    }
}



//根据传入的角色返回菜单
function roleReturnMenu(role: roleTypes) {

    const res = (Object.keys(menus)
        .filter((key: IFrontRouterConfigKey) =>
            menus[key].roles.includes(role))) as IFrontRouterConfigKey[]

    const result: IKey[] = []




    res.forEach((key: IFrontRouterConfigKey) => {
        result.push(menus[key])
    })

    //    console.log("res", res);
    //    console.log(666,result);
    return result

}
roleReturnMenu(roleTypes.farmer)

export { roleReturnMenu }
